﻿<%@ Page Language="C#"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="JSClass" %>
<%

    String layername = Request["layername"] == null ? "" : Request["layername"];
    String fieldvalue = Request["fieldvalue"] == null ? "" : Request["fieldvalue"];
    String geometry = Request["geometry"] == null ? "" : Request["geometry"];
	
	StringBuilder sb = new StringBuilder();
	
	sb.Append("INSERT INTO " + layername + " \n");
	sb.Append("VALUES \n");
	sb.Append("( \n");
	sb.Append("        SDE.VERSION_USER_DDL.NEXT_ROW_ID \n");
	sb.Append("        ( \n");
	sb.Append("                'EXGIS2011' ,  \n");
	sb.Append("                (SELECT REGISTRATION_ID FROM SDE.TABLE_REGISTRY WHERE OWNER='EXGIS2011' AND TABLE_NAME=UPPER('" + layername + "')) \n");
	sb.Append("        ) ,  \n");
	sb.Append("        '" + fieldvalue + "' ,  \n");
	sb.Append("        SDE.ST_GEOMETRY( \n");
	sb.Append("                " + geometry + ", \n");
	sb.Append("                (SELECT SRID FROM SDE.ST_GEOMETRY_INDEX WHERE TABLE_NAME=UPPER('" + layername + "')) \n");
	sb.Append("        ) \n");
	sb.Append(") \n");
	
	try
    {
        ExecuteQuery executeQuery = new ExecuteQuery();
        executeQuery.executeQuery(sb.ToString());

		//Response.Write("{\"success\" : true}");
		//Response.Write(sb.ToString());
		Response.End();
    }
    catch (Exception aa)
    {
        //Response.Write("{\"success\" : false}");
		//Response.Write(sb.ToString());
		Response.Write(fieldvalue);
		Response.End();
    }
%>